// components/record/record.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    recordObj:{
      type:Object,
      value:null
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    createTime:"",
    completeTime:""
  },
  attached(){
    this.setData({
      createTime:this.formateTime(this.data.recordObj.createTime),
      completeTime:this.formateTime(this.data.recordObj.completeTime)
    })
   },
  methods: {
    formateTime(time){
      // 订单时间
      let date = new Date(time);
      let y = date.getFullYear();
      let m = date.getMonth()+1;
      let d = date.getDate();
      let hh = date.getHours();
      let mm = date.getMinutes();
      m = m<10?"0"+m:m;
      d  = d <10?"0"+d :d ;
      hh = hh<10?"0"+hh:hh;
      mm = mm<10?"0"+mm:mm;
      return `${y}年${m}月${d}日 ${hh}:${mm}`
    },
    conact(){
      wx.makePhoneCall({
        phoneNumber:this.data.recordObj.workerPhone
      }).then(res=>{
        console.log(res);
      })
    },
    switchPage(){
      let obj = this.data.recordObj;
      wx.navigateTo({
        url: '/pages/CompletedOrder/CompletedOrder?id='+obj._id,
      })
    }
  }
})
